package com.sm.user.service.impl;

/**
 * @program: practice
 * @description:
 * @author: liqitian.
 * @create: 2019-11-18 10:16
 **/

import com.sm.tool.entity.response.ReturnData;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

/**
 * 简化service（所有s共同ervice应）
 */
public abstract class BaseSimplifyService {

    ResponseEntity<ReturnData> Re(ReturnData returnData) {
        HttpStatus httpStatus = null;
        int code = returnData.getCode();
        if (code >= 2000){
            httpStatus = HttpStatus.OK;
        }else if (code >= 4000){
            httpStatus = HttpStatus.BAD_REQUEST;
        }
        else if(code >= 5000){
            httpStatus = HttpStatus.INTERNAL_SERVER_ERROR;
        }

        return new ResponseEntity(returnData,httpStatus);
    }
}
